﻿using System;
using UnityEngine;
using UnityEngine.UI;

public class ScrollSelectItem : MonoBehaviour
{
    public Text text;

    public Color activeColor = Color.white;
    public Color disActiveColor = Color.white;

    bool actived;

    string m_Value;
    public string value => m_Value;

    void Start()
    {

    }

    public void Init(string value)
    {
        m_Value = value;
        this.text.text = value;
    }

    public void ShowActive(bool anim = true)
    {
        actived = true;
        text.color = this.activeColor;

        if (!anim)
            transform.localScale = Vector3.one;
    }
    public void ShowDisctive(bool anim = true)
    {
        actived = false;
        text.color = this.disActiveColor;

        if (!anim)
            transform.localScale = .7f * Vector3.one;
    }

    void Update()
    {
        if (actived)
        {
            transform.localScale = Vector3.Lerp(transform.localScale, Vector3.one, 0.2f);
        }
        else
        {
            transform.localScale = Vector3.Lerp(transform.localScale, .7f * Vector3.one, 0.2f);
        }
    }
}
